package com.sgb.kjwl.repository.impl;

import com.sgb.kjwl.model.api.ApiSource;
import com.sgb.kjwl.model.api.PreferenceSource;
import com.sgb.kjwl.model.entity.AddShoppingCar;
import com.sgb.kjwl.model.entity.MaterialCompanyEntity;
import com.sgb.kjwl.model.entity.MaterialDetailEntity;
import com.sgb.kjwl.model.entity.STFilterEntity;
import com.sgb.kjwl.model.entity.SearchMaterialEntity;
import com.sgb.kjwl.model.entity.SearchMaterialEntity3;
import com.sgb.kjwl.model.entity.request.MaterialFilterJson;
import com.sgb.kjwl.model.entity.request.MaterialFilterJson3;
import com.sgb.kjwl.model.entity.supplier3.DictEntity3;
import com.sgb.kjwl.model.entity.user.SearchSTEntity;
import com.swgk.core.base.model.entity.ListResponse;
import com.sgb.kjwl.repository.MaterialRepertory;
import com.swgk.core.base.api.BaseApiSource;
import com.swgk.core.base.model.entity.BaseEntity;
import com.swgk.core.base.model.preference.BasePreferenceSource;

import java.util.List;
import java.util.Map;

import io.reactivex.Observable;

public class MaterialRepertoryImpl extends BaseRepertoryImpl implements MaterialRepertory {

    private ApiSource apiSource;
    private PreferenceSource preferenceSource;

    public MaterialRepertoryImpl(BaseApiSource apiSource, BasePreferenceSource preferenceSource) {
        super(apiSource, preferenceSource);
        this.apiSource = (ApiSource) apiSource;
        this.preferenceSource = (PreferenceSource) preferenceSource;
    }

    @Override
    public Observable<BaseEntity<MaterialDetailEntity>> getMaterialDetail(String pid, String areacode) {
        return apiSource.getMaterialDetail(pid, areacode).compose(this.<BaseEntity<MaterialDetailEntity>>rxSchedulerHelper());
    }

    @Override
    public Observable<BaseEntity> checkToken(Map map) {
        return apiSource.checkToken(map).compose(this.<BaseEntity>rxSchedulerHelper());
    }

    @Override
    public Observable<BaseEntity<List<DictEntity3>>> getMaterialFilterType(String id, String areacode) {
        return apiSource.getMaterialFilterType(id, areacode).compose(rxSchedulerHelper());
    }

    @Override
    public Observable<BaseEntity<List<DictEntity3>>> getMaterialFilterName(String id, String areacode) {
        return apiSource.getMaterialFilterName(id, areacode).compose(rxSchedulerHelper());
    }

    @Override
    public Observable<BaseEntity<List<DictEntity3>>> getMaterialFilterStore(String areacode) {
        return apiSource.getMaterialFilterStore(areacode).compose(rxSchedulerHelper());
    }

    @Override
    public Observable<BaseEntity<List<DictEntity3>>> getMaterialFilterBrand(String id, String areacode) {
        return apiSource.getMaterialFilterBrand(id, areacode).compose(rxSchedulerHelper());
    }

    @Override
    public Observable<BaseEntity<List<DictEntity3>>> getMaterialFilterSpec(String id, String areacode) {
        return apiSource.getMaterialFilterSpec(id, areacode).compose(rxSchedulerHelper());
    }

    @Override
    public Observable<BaseEntity<List<DictEntity3>>> getMaterialDistanceData() {
        return apiSource.getMaterialDistanceData().compose(rxSchedulerHelper());
    }

    @Override
    public Observable<BaseEntity<List<DictEntity3>>> getMaterialPriceData() {
        return apiSource.getMaterialPriceData().compose(rxSchedulerHelper());
    }

    @Override
    public Observable<BaseEntity<ListResponse<List<SearchMaterialEntity>>>> getMaterialList(MaterialFilterJson materialFilterJson) {
        return apiSource.getMaterialList(materialFilterJson).compose(rxSchedulerHelper());
    }

    @Override
    public Observable<BaseEntity<MaterialCompanyEntity>> getMaterialCompany(String cid, String areacode) {
        return apiSource.getMaterialCompany(cid, areacode).compose(this.<BaseEntity<MaterialCompanyEntity>>rxSchedulerHelper());
    }

    @Override
    public Observable<ListResponse<List<SearchMaterialEntity>>> getMaterialFilterList(int page, int size, int sort, Map map) {
        return apiSource.getMaterialFilterList(page, size, sort, map).compose(this.rxSchedulerHelper());
    }

    @Override
    public Observable<BaseEntity> addShoppingCar(AddShoppingCar addShoppingCar) {
        return apiSource.addShoppingCar(addShoppingCar).compose(this.rxSchedulerHelper());
    }

    @Override
    public Observable<BaseEntity<String>> getCarCount(String areacode) {
        return apiSource.getCarCount(areacode).compose(this.rxSchedulerHelper());
    }

//    @Override
//    public Observable<BaseEntity<ListResponse<List<SearchSTEntity>>>> getSTList(MaterialFilterJson materialFilterJson) {
//        return apiSource.getSTList(materialFilterJson).compose(rxSchedulerHelper());
//    }

    @Override
    public Observable<BaseEntity<STFilterEntity>> getSTFilter(String areaCode) {
        return apiSource.getSTFilter(areaCode).compose(rxSchedulerHelper());
    }

    @Override
    public Observable<BaseEntity<ListResponse<List<SearchMaterialEntity3>>>> getMaterialList3(MaterialFilterJson3 materialFilterJson) {
        return apiSource.getMaterialList3(materialFilterJson).compose(rxSchedulerHelper());
    }
}
